/* $Id:person_items.h $ */
/*
   Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
   Part of the Moros Project http://moros.sourceforge.net/

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 3.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details.
*/

#ifndef __PERSON_ITEMS_H
#define __PERSON_ITEMS_H

#include <string>
#include <map>
#include <list>
using namespace std;

#include "stat_amount.h"
#include "action_level.h"

#define loopPerson_itemsStats(r,v) loopMap((r)->listStats(),v,class stat_amount)
#define loopPerson_itemsUsage(r,v) loopMapi((r)->listUsage(),v,class action_level)

class person_items {
    class item *type;
    int damage;
    map<string,class stat_amount> stats;
    map<int,class action_level> usage;
    int maxUsage;
    int points;
    int position;
    class person *owner;
public:
    person_items();

    // Field : type
    class item& getType() const;
    void setType(class item &v);

    // Field : damage
    const int getDamage() const;
    void setDamage(const int v);

    // Field : stats
    class stat_amount& getStats(const string v);
    map<string,class stat_amount>& listStats();
    void setStats(class stat_amount &v);
    void delStats(const string v);
    const bool isStats(const string v) const;

    // Field : usage
    class action_level& getUsage(const int v);
    map<int,class action_level>& listUsage();
    void setUsage(class action_level &v);
    void delUsage(const int v);
    const bool isUsage(const int v) const;

    // Field : points
    const int getPoints() const;
    void setPoints(const int v);

    // Field : position
    const int getPosition() const;
    void setPosition(const int v);
    const string showPosition() const;

    // Field : owner
    class person& getOwner() const;
    void setOwner(class person &v);
    int operator<(const class person_items &ck) const;

    void save(class channel &ch);
    void load(class channel &ch);
    void xml(ofstream &f, int l=0, int r=0);
};

#endif // __PERSON_ITEMS_H
